package org.chl.chapter05.logic;

import java.util.List;

import org.chl.chapter05.dao.BookDao;
import org.chl.chapter05.model.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BookLogic {
	@Autowired
	BookDao bookDao;

	public Book save(Book book) {
		return bookDao.save(book);
	}

	public void deleteBookById(Integer id) {
		bookDao.deleteById(id);;
	}

	public Book getBookById(Integer id) {
		return bookDao.getOne(id);
	}

	public List<Book> getAllBooks() {
		return bookDao.findAll();
	}

}
